<template>
  <div class="leftBox">
    <ul>
      <li
        v-for="(item, i) in lList"
        :key="i"
        @click="change(i)"
        :class="{ active: idx == i }"
      >
        {{ item.name }}
      </li>
    </ul>
  </div>
</template>

<script>
import { ref, reactive, toRefs } from "vue";
import { useStore } from "vuex";
import { useRouter, useRoute } from "vue-router";
export default {
  name: "",
  props: ["lList"],
  setup(props, cxt) {
    const router = useRouter();
    const route = useRoute();
    const store = useStore();
    const data = reactive({
      idx: "", //当前点击的下边
    });
    // 切换分类事件
    const change = (i) => {
      data.idx = i;
      //   子传父
      cxt.emit("getRight", i);
    };
    return {
      ...toRefs(data),
      change,
    };
  },
};
</script>

<style scoped lang='scss'>
.leftBox {
  background-color: #f9f6f6;
  height: calc(
    100% - 277px
  ); //calc() 此 CSS 函数允许在声明 CSS 属性值时执行一些计算
  width: 30%;
  position: fixed;
  overflow: scroll;
  ul {
    li {
      width: 100%;
      height: 50px;
      text-align: center;
      line-height: 50px;
      color: #666;
      font-size: 12px;
    }
    .active {
      background-color: #fff;
      font-weight: 600;
    }
  }
}
</style>